package com.yunfangdata.web.controller;

import com.yunfangdata.domain.Curriculumseries;
import com.yunfangdata.query.QueryObject;
import com.yunfangdata.service.ICurriculumseriesService;
import com.yunfangdata.util.JsonResult;
import com.yunfangdata.util.PageResult;
import com.yunfangdata.util.PermissionName;
import org.apache.shiro.authz.annotation.RequiresPermissions;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Controller;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.ResponseBody;

@Controller
@RequestMapping("curriculumseries")
public class CurriculumseriesController {

        @Autowired
        private ICurriculumseriesService curriculumseriesService;

    @RequestMapping("")
    @RequiresPermissions("curriculumseries:index")
    @PermissionName("课程首页")
    public String index(){
        return "curriculumseries/list";
    }

    @RequiresPermissions("curriculumseries:list")
    @PermissionName("课程列表")
    @RequestMapping("list")
    @ResponseBody
    public PageResult list(QueryObject qo){
        System.out.println(curriculumseriesService.query(qo));
        return curriculumseriesService.query(qo);
    }



    @RequestMapping("save")
    @ResponseBody
    @RequiresPermissions("curriculumseries:save")
    @PermissionName("课程保存")
    public JsonResult save( Curriculumseries entity){
        JsonResult result = new JsonResult();
        try {
            curriculumseriesService.save(entity);
        }catch (Exception e){
            e.printStackTrace();
            result = new JsonResult("保存操作失败");
        }
        return result;
    }

    @RequestMapping("update")
    @ResponseBody
    @RequiresPermissions("curriculumseries:update")
    @PermissionName("课程更新")
    public JsonResult update(Curriculumseries entity){
        JsonResult result = new JsonResult();
        try {
            curriculumseriesService.update(entity);
        }catch (Exception e){

            e.printStackTrace();
            result = new JsonResult("更新操作失败");
        }
        return result;
    }





}
